package com.laicunba.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.laicunba.pojo.FinancingTargetDO;
import com.laicunba.pojo.vo.PositionConditionVO;

public interface FinancingTargetService extends BaseService {

	boolean create(FinancingTargetDO entity);

	Map<String, Integer> listStatusCount();

	List<FinancingTargetDO> findByStatus(String status);

	/**
	 * 检查对资记录是对的
	 * 
	 * @return
	 */
	boolean checkBidRecordIsRight(String financingTargetId);

	FinancingTargetDO findByCode(String targetCode);

	FinancingTargetDO getSaleAble(String financingTargetId);

	boolean subtractStock(String financingTargetId, BigDecimal amount);

	/**
	 * 通过位置查找
	 * 
	 * @param condition
	 * @return
	 */
	List<FinancingTargetDO> findByPosition(PositionConditionVO condition);

	/**
	 * 得到开始计息的第一天 <br>
	 * 默认为: PROFIT_FLAG_NEXT_WORK_DAY</br>
	 * 
	 * @param profitFlag
	 * @param payedTime
	 * @return
	 */
	Date getFirstProfitDate(String profitFlag, Date payedTime);

	/**
	 * 改变状态
	 * 
	 * @param fromStatus
	 * @param toStatus
	 * @param id
	 * @return
	 */
	boolean changeStatus(String fromStatus, String toStatus, String id);

	/**
	 * 查找一个在售中的,指定标记的标的,并且它的可售额度要大于指定的额度
	 * 
	 * @param tag
	 * @param amount
	 * @return
	 */
	FinancingTargetDO find(String tag, BigDecimal amount);

}
